<?php 
defined('BASEPATH') OR exit('No direct script access allowed');
require_once FCPATH.'/ctcms/libs/phpTree.php';
class Users extends Ctcms_Controller{
	function __construct(){

	    parent::__construct();

	}

	public function index()

	{
		 
		 $where["id"]=$this->input->get("id");
		 $arr=$this->csdb->get_select('user','*',$where,'id DESC',"");
	  // $arr=json_decode(json_encode($arr),true);//要吐血的这一步
		echo json_encode($arr);
    }

    public function save()

	{

		if($_SERVER['REQUEST_METHOD']!="POST"){
    		echo '{"status":0,"msg":"請求方式不對"}';
    		exit();
    	}else{
    		 parse_str(file_get_contents("php://input"), $param);
    		 try{
    		 	$result_id=$this->csdb->get_insert('user',$param);
    		 	echo '{"status":1,"msg":"添加成功","id":'.$result_id.'}';
                 
            } catch (Exception $e) {
				print $e->getMessage();
				exit();
            }
         }
	}

}